import java.util.Calendar;
import java.util.Vector;


public class checkRooms {
	// data control
	private roomManager rm;
	private roomManagementDialog rmd;
		
	public checkRooms(roomManager initrm){
		rm = initrm;
		
		host tempHost;
		Calendar now = Calendar.getInstance();
		
		System.out.println("checking");
		//check using rooms
		for(int i=1;i<17;i++){
			tempHost = rm.getCurrentHost(i);
			if(tempHost.getAge()!=-1){
				if(now.compareTo(tempHost.getEndTime())>0){
					rm.searchRoom(tempHost.getRoomNum()).initialize();
					rm.deleteHost(tempHost);
					System.out.println("one host check out");
				}
				}
		}
		
		//check reservations
		for(int i=1;i<17;i++){		
			if(!rm.getReservations(i).isEmpty()){
				tempHost = rm.getReservations(i).firstElement();
				if(tempHost.getAge()!=-1){
					if(now.compareTo(tempHost.getStartTime())>0){
						rm.addCurrentHost(tempHost);
						rm.updateRoomState(tempHost.getRoomNum(), 1);
					//rmd.afterCreate(tempHost.getRoomNum());
						rm.deleteHost(tempHost);
						System.out.println("one host check in");
					}
				}
			}
		}
		
	}
	
	
}
